home *** CD-ROM | disk | FTP | other *** search
/ Champak 125 / Vol 125 (Damaged).iso / games / rabbit_r.swf / scripts / __Packages / smashing / keithm / BaseCamera.as next >
Encoding:
Text File  |  2009-06-09  |  2.3 KB  |  101 lines

  1. class smashing.keithm.BaseCamera
  2. {
  3.    var __dimensions;
  4.    var x;
  5.    var y;
  6.    var z;
  7.    var fl;
  8.    var farClip;
  9.    var __bound_left;
  10.    var __bound_right;
  11.    var __bound_top;
  12.    var __bound_bottom;
  13.    var left;
  14.    var right;
  15.    var top;
  16.    var bottom;
  17.    var __DEF_CLIP = 100000;
  18.    var fl_DEF = 1000;
  19.    var __EDGE_PADDING = 50;
  20.    function BaseCamera(t_data)
  21.    {
  22.       this.__dimensions = t_data.dimensions;
  23.       this.x = this.y = this.z = 0;
  24.       if(t_data.x != undefined)
  25.       {
  26.          this.x = t_data.x;
  27.       }
  28.       if(t_data.y != undefined)
  29.       {
  30.          this.y = t_data.y;
  31.       }
  32.       if(t_data.z != undefined)
  33.       {
  34.          this.z = t_data.z;
  35.       }
  36.       this.fl = this.fl_DEF;
  37.       this.farClip = this.__DEF_CLIP;
  38.       this.refreshEdges();
  39.    }
  40.    function update(dt)
  41.    {
  42.    }
  43.    function setBounds(left, right, top, bottom)
  44.    {
  45.       this.__bound_left = left + this.__dimensions.HALF_WIDTH;
  46.       this.__bound_right = right - this.__dimensions.HALF_WIDTH;
  47.       this.__bound_top = top + this.__dimensions.HALF_HEIGHT;
  48.       this.__bound_bottom = bottom - this.__dimensions.HALF_HEIGHT;
  49.    }
  50.    function enforceBounds()
  51.    {
  52.       if(this.x < this.__bound_left)
  53.       {
  54.          this.x = this.__bound_left;
  55.       }
  56.       else if(this.x > this.__bound_right)
  57.       {
  58.          this.x = this.__bound_right;
  59.       }
  60.       if(this.y < this.__bound_top)
  61.       {
  62.          this.y = this.__bound_top;
  63.       }
  64.       else if(this.y > this.__bound_bottom)
  65.       {
  66.          this.y = this.__bound_bottom;
  67.       }
  68.    }
  69.    function refreshEdges()
  70.    {
  71.       this.left = this.x - this.__dimensions.HALF_WIDTH;
  72.       this.right = this.x + this.__dimensions.HALF_WIDTH;
  73.       this.top = this.y - this.__dimensions.HALF_HEIGHT;
  74.       this.bottom = this.y + this.__dimensions.HALF_HEIGHT;
  75.    }
  76.    function get sc()
  77.    {
  78.       return this.__dimensions.sc;
  79.    }
  80.    function screenWidth()
  81.    {
  82.       return this.__dimensions.SCREEN_WIDTH;
  83.    }
  84.    function screenHeight()
  85.    {
  86.       return this.__dimensions.SCREEN_WIDTH;
  87.    }
  88.    function halfWidth()
  89.    {
  90.       return this.__dimensions.HALF_WIDTH;
  91.    }
  92.    function halfHeight()
  93.    {
  94.       return this.__dimensions.HALF_HEIGHT;
  95.    }
  96.    function toString()
  97.    {
  98.       return "Camera : focus : " + this.x + " , " + this.y + " , " + this.z;
  99.    }
  100. }
  101.